import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    redirect: '/product/main', // 重定向
    /*路由嵌套*/
    children:[
        /*主页*/
      {
        path: '/product/main',
        name: 'other',
        component: () => import('../views/product/main/HomeMain.vue')
      },
        /*详情信息页*/
      {
        path: '/product/detail',
        name: 'other',
        component: () => import('../views/product/main/DetailMain.vue')
      },
        /*汽车展示列表*/
      {
        path: '/product/car-list',
        name: 'other',
        component: () => import('../views/product/main/CarListMain.vue')
      },
      /*Es汽车展示列表*/
      {
        path: '/product/es/car-list',
        name: 'other',
        component: () => import('../views/product/main/EsCarListMain.vue')
      },
    ]
  },
    /*用户个人中心页面*/
  {
    path: '/user-center',
    name: 'user-center',
    component: () => import(/* webpackChunkName: "about" */ '../views/user/UserCenterView'),
    children:[
      /*发布车源页面*/
      {
        path: '/user-center/add-new-car',
        name: 'other',
        component: () => import('../views/user/operate/AddNewCarView')
      },
      /*车源管理页面*/
      {
        path: '/user-center/manage-car',
        name: 'other',
        component: () => import('../views/user/operate/ManageCarView')
      },
      /*车源收藏页面*/
      {
        path: '/user-center/favorite-car',
        name: 'other',
        component: () => import('../views/user/operate/FavoriteCarView')
      },
      /*买车订单页面*/
      {
        path: '/user-center/buy-car',
        name: 'other',
        component: () => import('../views/user/operate/BuyCarView')
      },
      /*卖车订单页面*/
      {
        path: '/user-center/selling-car',
        name: 'other',
        component: () => import('../views/user/operate/SellingCarView')
      },
      /*用户信息页面*/
      {
        path: '/user-center/user-info',
        name: 'other',
        component: () => import('../views/user/operate/UserInfoView')
      },
      /*用户修改密码页面*/
      {
        path: '/user-center/user-update-password',
        name: 'other',
        component: () => import('../views/user/operate/UpdatePasswordView')
      },
    ]
  },

  {
    path: '/reg',
    name: 'reg',
    component: () => import(/* webpackChunkName: "about" */ '../views/user/RegView.vue')
  },
    /*管理员登陆后界面*/
  {
    path: '/admin',
    name: 'admin',
    component: () => import(/* webpackChunkName: "about" */ '../views/admin/AdminHomeView'),
    children:[
      {
        path: '/admin/brand/brandList',
        name: 'other',
        component: () => import('../views/admin/child/BrandListView')
      },
      {
        path: '/admin/brand/addNewBrand',
        name: 'other',
        component: () => import('../views/admin/child/BrandAddNewView')
      },
      {
        path: '/admin/order/orderList',
        name: 'other',
        component: () => import('../views/admin/child/OrderListView')
      },
      {
        path: '/admin/series/seriesList',
        name: 'other',
        component: () => import('../views/admin/child/SeriesListView')
      },
      {
        path: '/admin/brand/CarList',
        name: 'other',
        component: () => import('../views/admin/child/CarListView')
      },
    ]
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    path: '/test',
    name: 'about',
    component: () => import(/* webpackChunkName: "about" */ '../views/test.vue')
  },

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
